package com.rd.student.ruanjian.class1.duhang.Day0728;

import java.io.*;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;

public class Text {
    public static void main(String[] args) throws Exception {
        Scanner scanner =new Scanner(System.in);
        ArrayList<String> list = new ArrayList<>();
        String[] arr = {"郑成祥","王博","孙文卓","郑睿娴","王高博","李春泉","张睿","王星凯","柏云耀","高艺铭","周子贺","杜航"};
        System.out.println("请输入学生个数");
        int n = scanner.nextInt();
        Random random = new Random();
        for (int i = 0; i < n; i++) {
            int randomn = random.nextInt(arr.length);
            System.out.println(arr[randomn]);
        }
        File file = new File("all.txt");
        Writer writer = new FileWriter(file);
        String[] content = {"郑成祥","王博","孙文卓","郑睿娴","王高博","李春泉","张睿","王星凯","柏云耀","高艺铭","周子贺","杜航"};
        writer.write(String.valueOf(content));
        writer.close();

        File file1 = new File("random.txt");
        Reader reader = new FileReader(file1);
        char[] arr1 = new char[(int)file1.length()];
        reader.read(arr1);
        System.out.println(new String(arr1));
        reader.close();
    }
}

class Student{
    String name;

    public Student(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "学生=" +
                "姓名：" + name;
    }
}
